<%@ page import="myoa.domain.RoleName" %>
<html>
<head>
    <meta name="layout" content="freshmade">
</head>

<body>

<div id="content-wrapper">
    <div class="center-wrapper">
        <div class="content">
            <div id="main">
                <div class="post">
                    <div class="post-title">
                        <h1><g:message code="user.list"/></h1>
                        <g:render template="/template/messageBar"/>
                    </div>

                    <div class="post-date">
                        <g:render template="/template/listBar1" model="[size: users.size()]"/>
                    </div>
                </div>
                <table class="data-table">
                    <tr>
                        <th><g:message code="user.name"/></th>
                        <th><g:message code="user.lastLogin"/></th>
                        <th><g:message code="user.status"/></th>
                        <th><g:message code="user.resetPwd"/></th>
                        <th>${RoleName.Every}</th>
                        <th>${RoleName.EMP}</th>
                        <th>${RoleName.CRM}</th>
                        <th>${RoleName.PM}</th>
                        <th>${RoleName.ACC}</th>
                        <th>${RoleName.MGR}</th>
                        <th>${RoleName.SYS}</th>
                        <th><g:message code="user.permissions"/></th>
                    </tr>
                    <tbody>
                    <g:each in="${users}" status="i" var="u">
                        <tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
                            <td><g:link action="show" id="${u.id}">${u.name}</g:link></td>
                            <td><g:formatDate date="${u.lastLogin}"/></td>
                            <td>${u.status}</td>
                            <td><g:link action="resetPassword" id="${u.id}">${u.password.substring(0, 6)}</g:link></td>
                            <td><g:if test="${u.hasRole(RoleName.Every)}">*</g:if></td>
                            <td><g:if test="${u.hasRole(RoleName.EMP)}">*</g:if></td>
                            <td><g:if test="${u.hasRole(RoleName.CRM)}">*</g:if></td>
                            <td><g:if test="${u.hasRole(RoleName.PM)}">*</g:if></td>
                            <td><g:if test="${u.hasRole(RoleName.ACC)}">*</g:if></td>
                            <td><g:if test="${u.hasRole(RoleName.MGR)}">*</g:if></td>
                            <td><g:if test="${u.hasRole(RoleName.SYS)}">*</g:if></td>
                            <td>
                                <g:each in="${u.permissions}" status="k" var="permission">
                                    <g:if test="${k != 0}">|</g:if>  ${permission}
                                </g:each>
                            </td>
                        </tr>
                    </g:each>
                    </tbody>
                </table>
            </div>

            <div class="clearer">&nbsp;</div>
        </div>

    </div>
</div>

</body>
</html>